from __future__ import absolute_import
import sys
sys.path.append('./src')
from src.inference import MyModel
import argparse
import yaml
import logging


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--conf', help="conf file", default="../geo_server/conf/server.yml", type=argparse.FileType('r'))
    parser.add_argument('-i', '--img', help="img to be detected")
    return parser.parse_args()


def main(args):
    conf = yaml.load(args.conf)
    logging.warning('China GCJ-02 convert state: ' + str(args.china_convert))
    model = MyModel(conf, ext='jpg')
    return model.detect_one_img(args.img)


if __name__ == '__main__':
    args = parse_args()
    logging.basicConfig(level=logging.INFO)
    print(main(args))
